<template>
  <div class="login-box flex-row-center">

    <div  class="login-form-box flex-col-center">

      <el-form ref="form" :model="form" label-width="80px" @keyup.enter="submit">
        <el-form-item label="账号">
          <el-input v-model="form.username"></el-input>
        </el-form-item>
        <el-form-item label="密码">
          <el-input type="password" v-model="form.password"></el-input>
        </el-form-item>
        <el-button
            border
            @click="submit"
        >
          登录
        </el-button>

      </el-form>

    </div>

  </div>
</template>

<script>
import userApi from "@/api/user/user";
import {TokenUtil} from "@/util/TokenUtil";

export default {
  name: "Login",
  data() {
    return {
      form:{
        username:"admin",
        password:"admin",
        code:"12345"
      }
    }
  },
  methods:{
    submit(){
      userApi.login(this.form).then(resp=>{
        if(resp.code === 200){
          this.$message.success("登录成功")
          console.log(resp.data)
          TokenUtil.setToken(resp.data)
          this.$router.push("/bg")
        }else{
          this.$message.error(resp.msg)
        }
      })
    }
  }

}
</script>

<style scoped lang="less">

.login-box {
  width: 100%;
  height: 100vh;
  overflow: hidden;
  background: url("@/static/img/login/login-bg.jpg") no-repeat center;
  background-size: cover;

  .login-form-box {
    position: relative;
    width: 30%;
    height: 400px;
    min-width: 300px;
    background-color: white;
    //background-color: #2B323D;
    color: #07897D;
    font-size: 20px;
    /*filter: blur(20px);*/
    box-shadow: var(--box-shadow);
    border-radius: 5px;
    z-index: 3;
    animation: rotateOneTurn 0.3s ease-in-out;

    .login-form {
      width: 70%;
      display: flex;
      flex-direction: column;
      justify-content: flex-end;
      align-items: center;
      z-index: 2;

      .login-input {

        margin: 15px 0;
        width: 80%;

      }

      .login-btn {
        margin-top: 5px;
        width: 150px;
      }

      div.login-form-menu-box {
        width: 100%;
        height: 50px;
        position: absolute;
        right: 0;
        bottom: 5px;

        .el-link {
          caret-color: transparent;
        }

      }
    }

    &:before {
      content: " ";
      position: absolute;
      width: 30%;
      aspect-ratio: 1;
      top: 0;
      left: 50%;
      transform: translate(-50%, -50%);
      z-index: 0;
      border-radius: 50%;
      background: url("@/static/img/login/login-logo.jpeg") no-repeat center;
      background-size: cover;
      box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.2);
    }
  }
}
</style>